//package com.plian.system.service.yth.impl;
//
//import com.baomidou.dynamic.datasource.annotation.DS;
//import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
//import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
//import com.plian.Tools.CollectionUtil;
//import com.plian.system.entity.yth.finance.DebtProject;
//import com.plian.system.mapper.yth.finance.DebtProjectMapper;
//import com.plian.system.service.yth.IDebtProjectService;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.stereotype.Service;
//import org.springframework.transaction.annotation.Propagation;
//import org.springframework.transaction.annotation.Transactional;
//
//import java.util.*;
//
///**
// * @Description:
// * @Author: jatpen
// * @Date: 2023/5/10 1:56 PM
// */
//@Slf4j
//@Service
//public class DebtProjectServiceImpl extends ServiceImpl<DebtProjectMapper, DebtProject> implements IDebtProjectService {
//
//
//    private final String YTH_DATASOURCE_TYPE = "3";
//
//
//    @Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
//    @DS("slave_1")
//    @Override
//    public List<InvestmentDebtInfo> getSyncData(Date startTime, Date endTime) {
//        List<InvestmentDebtInfo> investmentDebtInfoList = new ArrayList<>();
//        List<DebtProject> debtProjects = list(new LambdaQueryWrapper<DebtProject>()
//                .gt(Optional.ofNullable(startTime).isPresent(), DebtProject::getCreateTime, startTime)
//                .le(Optional.ofNullable(endTime).isPresent(), DebtProject::getCreateTime, endTime));
//        if (CollectionUtil.isNotEmpty(debtProjects)) {
//            investmentDebtInfoList = conversion(debtProjects);
//        }
//        return investmentDebtInfoList;
//    }
//
//    /**
//     * 转换对象
//     *
//     * @param debtProjects
//     * @return
//     */
//    private List<InvestmentDebtInfo> conversion(List<DebtProject> debtProjects) {
//        List<InvestmentDebtInfo> investmentDebtInfoList = new ArrayList<>();
//        for (DebtProject debtProject : debtProjects) {
//            InvestmentDebtInfo investmentDebtInfo = new InvestmentDebtInfo();
//            investmentDebtInfo.setProjectName(debtProject.getDebtProjectName());
//            investmentDebtInfo.setProjectCompanyId(Objects.toString(debtProject.getProjectCompanyId(), null));
//            investmentDebtInfo.setIsFundInvestment(debtProject.getIsFundInvest());
//            investmentDebtInfo.setConstructionStatus(debtProject.getProjectDev());
//            investmentDebtInfo.setBalancedPlanning(debtProject.getBalancePlan() == null ? null : debtProject.getBalancePlan().toString());
//            investmentDebtInfo.setPlanTotalInvestment(debtProject.getTotalPlanInvest());
//            investmentDebtInfo.setFiscalFunds(debtProject.getFinanceFund());
//            investmentDebtInfo.setShareholderCapital(debtProject.getShareholderFund());
//            investmentDebtInfo.setProjectLoan(debtProject.getProjectLoan());
//            investmentDebtInfo.setCreateCompanyId(Objects.toString(debtProject.getReportOrgId(), null));
//            investmentDebtInfo.setCreateUser(Objects.toString(debtProject.getReportUserId()));
//            investmentDebtInfo.setDataSource(YTH_DATASOURCE_TYPE);
//            investmentDebtInfo.setDataSourceId(debtProject.getId().toString());
//            investmentDebtInfo.setStatus(0);
//            investmentDebtInfoList.add(investmentDebtInfo);
//        }
//        return investmentDebtInfoList;
//    }
//}
